/****************************************************
    ScriptName:        Invoke.cs
    Author:            86191
    CreatTime:    2020/12/15 19:6:15
    Description:     nothing
*****************************************************/


using System.Collections;
using System.Collections.Generic;
using UnityEngine;


namespace HXY
{
    public class Drag : MonoBehaviour
    {
        int cnt;
        private Vector2 _OriginSize;
        // Start is called before the first frame update
        void Start()
        {
            _OriginSize = gameObject.GetComponent<RectTransform>().sizeDelta;
            cnt = 0;
        }

        // Update is called once per frame
        void Update()
        {
            transform.position = Input.mousePosition;
            if (Input.GetMouseButton(0))
            {
                cnt++;
                if (cnt <= 10)
                {
                    gameObject.GetComponent<RectTransform>().sizeDelta = new Vector2(gameObject.GetComponent<RectTransform>().rect.width + 2, gameObject.GetComponent<RectTransform>().rect.height + 2);
                }
                else if(cnt<=20)
                {
                    gameObject.GetComponent<RectTransform>().sizeDelta = new Vector2(gameObject.GetComponent<RectTransform>().rect.width - 1, gameObject.GetComponent<RectTransform>().rect.height - 1);
                }
                else
                {
                    gameObject.GetComponent<RectTransform>().sizeDelta = _OriginSize;
                    cnt = 0;
                }
                
            }
            if(Input.GetMouseButtonUp(0))
            {
                gameObject.GetComponent<RectTransform>().sizeDelta = _OriginSize;
                cnt = 0;
            }
        }
        
    }
    
}


